﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Flourish — PHP Unframework</title>
  <meta name="description" content="A modular and portable general-purpose, object-oriented PHP library focused on usability, documentation and security and licensed under the MIT license.">
  <?php echo $this->Html->css('site'); ?>
  <script type="text/javascript" src="/img/trac.js"></script>
  <meta name="attribution" content="Code Repository icons from http://www.famfamfam.com/lab/icons/silk/">
  <meta name="verify-v1" content="kTg9BLsDLvfjCAvuTxcniw9+tap5BDBeN0Xs/MfOYFE=">
  <meta name="msvalidate.01" content="69478FBEB92A4D48978C7A96081FDDF8">
  <meta name="y_key" content="26345003a345314a">
<script src="/img/in.php" async="" type="text/javascript"></script></head>
<body>





<div id="header">
	<a href="http://flourishlib.com/" id="logo"><img src="/img/header_logo_beta.gif" alt="Flourish"></a>
	<form action="/search" method="get">
		<div>
			<input style="color: rgb(153, 153, 153);" name="q" value="Search…" type="text">
			<input name="noquickjump" value="1" type="hidden">
			<noscript>
				<div class="button">
					<input type="submit" value="Go" />
				</div>
			</noscript>
		</div>
	</form>
	<ul><li class="first"><a accesskey="1" href="http://flourishlib.com/docs">Documentation</a></li><li><a href="http://flourishlib.com/docs/Download">Download</a></li><li><a href="http://flourishlib.com/browser">Code</a></li><li><a href="http://flourishlib.com/docs/Tests">Tests</a></li><li><a accesskey="7" href="http://flourishlib.com/newticket">Tickets</a></li><li><a href="http://flourishlib.com/discussion">Discussion</a></li><li><a accesskey="2" href="http://flourishlib.com/timeline">Project</a></li><li class="last"><a href="http://flourishlib.com/blog">Blog</a></li></ul>
</div>
<div id="main">




<div id="ctxtnav" class="nav">
 <h2>Wiki Navigation</h2>
 <!--
 
 -->
</div>  

<div id="content" class="wiki">

 
  
  
   
   <div>
	<div id="searchable">
		<div class="actions">
<div class="main_actions">
    <div class="download">
        <a href="http://flourishlib.com/docs/Download">
            Download Now<br>
            <em>Current version: <strong>r969</strong></em>
        </a>
    </div>
    <div class="getting_started">
        <a href="http://flourishlib.com/docs/GettingStarted">Getting Started</a>
    </div>
    <div class="how_do_i">
        <a href="http://flourishlib.com/docs/HowDoI">How Do I …</a>
    </div>
    <div class="documentation">
        <a href="http://flourishlib.com/docs">Documentation</a>
    </div>
    </div>
    <div class="more_info">
    <p class="beta">
        Flourish is currently in <strong>beta</strong>. For information about the release schedule, please see the <strong><a href="http://flourishlib.com/docs/Roadmap">roadmap</a></strong>.
    </p>
    <h2><a href="http://flourishlib.com/blog">Flourish Blog</a></h2>
    <ul class="recent_blogs">
                        <li><a href="http://flourishlib.com/blog/PHPFloatingPointBug">PHP Floating Point Bug</a> <small>1/14/11</small></li>
                        <li><a href="http://flourishlib.com/blog/60000Tests">Testing Across 12 OSes, 10 Versions of PHP and 6 Databases</a> <small>8/4/10</small></li>
                        <li><a href="http://flourishlib.com/blog/OfflineDocumentation">Offline Documentation</a> <small>8/2/10</small></li>
                        <li><a href="http://flourishlib.com/blog/DoYouUseODBC">Do You Use ODBC?</a> <small>6/22/10</small></li>
                        <li><a href="http://flourishlib.com/blog/DB2SupportAdded">DB2 Support Added</a> <small>4/14/10</small></li>
		</ul>
    <h2>Thank You!</h2>
    <p>We just wanted to say thanks to those who have contributed to the project — <a href="http://flourishlib.com/docs/Support#ThankYou">see who</a>.
    </p>
    <p>Interested in supporting the project? Visit the <a href="http://flourishlib.com/docs/Support">Support page</a>.</p>
    <h2>Around the Web</h2>
    <ul class="social">
	<li>
		<a href="http://twitter.com/flourishlib">
			<img src="/img/twitter.gif" alt="(Twitter Icon)">
			Twitter
		</a>
	</li>
	<li>
        <a href="http://ohloh.net/p/flourish/">
			<img src="/img/ohloh.gif" alt="(Ohloh Icon)">
			Ohloh
		</a>
	</li>
	<li>
		<a href="http://github.com/wbond/flourish">
			<img src="/img/github.gif" alt="(GitHub Icon)">
			GitHub
		</a>
	</li>
	<li>
		<a href="http://bitbucket.org/wbond/flourish">
			<img src="/img/bitbucket.gif" alt="(Bitbucket Icon)">
			Bitbucket
		</a>
	</li>
	<li>
		<a href="http://launchpad.net/flourish">
		<img src="/img/launchpad.gif" alt="(Launchpad Icon)">
			Launchpad
		</a>
	</li>
	<li>
		<a href="http://webchat.freenode.net/?channels=#flourishlib">
		<img src="/img/irc.gif" alt="(IRC Icon)">
		IRC
		</a>
	</li>
</ul>
</div>
</div>

<div class="intro">
<h1 class="home"><strong>Flourish</strong> is a PHP <em>unframework</em> — a general-purpose, object-oriented library.</h1>
It has a modular architecture, meaning it <em>isn’t strictly MVC</em>. It focuses on being <strong><a href="http://flourishlib.com/docs/Security">secure</a></strong>, <strong><a href="http://flourishlib.com/docs">well documented</a></strong> and <strong>easy to use</strong>, while solving problems <em>intrinsic</em> to web development.
</div>
<h2 id="WhyUseFlourish">Why Use Flourish?<a title="Link to this section" class="anchor" href="http://flourishlib.com/#WhyUseFlourish"> ¶</a></h2>
<p>You will find Flourish useful if you need to write code that is any of the following:</p>
<ul class="why_first">
    <li>Secure</li>
    <li>Consistent and easy to understand</li>
    <li>Needs to model simple or complex databases, especially existing schemas</li>
    <li>Works with international data</li>
    <li>Can perform accurate math calculations</li>
    <li>Easily manipulates images</li>
</ul>
<ul class="why_second">
    <li>Able to run on different databases (MySQL, PostgreSQL, SQLite, MSSQL, Oracle, DB2)</li>
    <li>Can be used on closed-source projects</li>
    <li>Needs to run on PHP 5.1.6</li>
    <li>Needs an architecture other than MVC</li>
    <li>Plays nicely with other libraries and frameworks</li>
</ul>
<div class="why_clear"></div>

<script type="text/javascript">
<!--
$(function(){
    var p = $('<p>Want to see more? </p>');
    var a = $('<a href="#">Show how to upload an image, resize it and make a thumbnail</a>');
    a.click(function(){
        $('#user_example').hide();
        $('#image_example').show();
        return false;
    });
    p.append(a);
    $('#user_example').append(p);
    
    var p2 = $('<p>Looking for the original? </p>');
    var a2 = $('<a href="#">Switch back to find all users and printing their names</a>');
    a2.click(function(){
        $('#image_example').hide();        
        $('#user_example').show();
        return false;
    });
    p2.append(a2);
    $('#image_example').append(p2);

    $('#image_example').hide();
});

-->
</script>
<h2>View Example Code</h2>
<div id="user_example">
<p>Below is an example of how to retrieve all active users from the database and print their name.</p>
<div class="code php"><pre><span class="php-comment">//</span><span class="php-comment"> Connect to our SQLite database</span>
<span class="php-identifier">fORMDatabase</span><span class="php-code">::</span><span class="php-identifier">attach</span><span class="php-brackets">(</span><span class="php-reserved">new</span> <span class="php-identifier">fDatabase</span><span class="php-brackets">(</span><span class="php-quotes">'</span><span class="php-string">sqlite</span><span class="php-quotes">'</span><span class="php-code">, </span><span class="php-quotes">'</span><span class="php-string">/path/to/database</span><span class="php-quotes">'</span><span class="php-brackets">)</span><span class="php-brackets">)</span><span class="php-code">;</span>
 
<span class="php-comment">//</span><span class="php-comment"> Create an object to represent rows in the database</span>
<span class="php-reserved">class</span> <span class="php-identifier">User</span> <span class="php-reserved">extends</span> <span class="php-identifier">fActiveRecord</span> <span class="php-brackets">{</span>
    <span class="php-comment">//</span><span class="php-comment"> Return an iterable set of User objects</span>
    <span class="php-reserved">public</span> <span class="php-reserved">static</span> <span class="php-reserved">function</span> <span class="php-identifier">findActive</span><span class="php-brackets">(</span><span class="php-brackets">)</span> <span class="php-brackets">{</span>
        <span class="php-reserved">return</span> <span class="php-identifier">fRecordSet</span><span class="php-code">::</span><span class="php-identifier">build</span><span class="php-brackets">(</span>
            <span class="php-quotes">'</span><span class="php-string">User</span><span class="php-quotes">'</span><span class="php-code">,                            </span><span class="php-comment">//</span><span class="php-comment"> Make User objects</span>
            <span class="php-reserved">array</span><span class="php-brackets">(</span><span class="php-quotes">'</span><span class="php-string">status=</span><span class="php-quotes">'</span><span class="php-code"> =&gt; </span><span class="php-quotes">'</span><span class="php-string">Active</span><span class="php-quotes">'</span><span class="php-brackets">)</span><span class="php-code">,      </span><span class="php-comment">//</span><span class="php-comment"> That are active</span>
            <span class="php-reserved">array</span><span class="php-brackets">(</span><span class="php-quotes">'</span><span class="php-string">date_registered</span><span class="php-quotes">'</span><span class="php-code"> =&gt; </span><span class="php-quotes">'</span><span class="php-string">desc</span><span class="php-quotes">'</span><span class="php-brackets">)</span> <span class="php-comment">//</span><span class="php-comment"> Ordered by registration date</span>
        <span class="php-brackets">)</span><span class="php-code">;</span>
    <span class="php-brackets">}</span>
<span class="php-brackets">}</span>
 
<span class="php-comment">//</span><span class="php-comment"> Loop through and display the users' names</span>
<span class="php-reserved">foreach</span> <span class="php-brackets">(</span><span class="php-identifier">User</span><span class="php-code">::</span><span class="php-identifier">findActive</span><span class="php-brackets">(</span><span class="php-brackets">)</span> <span class="php-reserved">as</span> <span class="php-var">$user</span><span class="php-brackets">)</span> <span class="php-brackets">{</span>
    <span class="php-reserved">echo</span> <span class="php-var">$user</span><span class="php-code">-&gt;</span><span class="php-identifier">prepareFirstName</span><span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-code"> . </span><span class="php-quotes">'</span><span class="php-string"> </span><span class="php-quotes">'</span><span class="php-code"> . </span><span class="php-var">$user</span><span class="php-code">-&gt;</span><span class="php-identifier">prepareLastName</span><span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-code"> . </span><span class="php-quotes">'</span><span class="php-string">&lt;br /&gt;</span><span class="php-quotes">'</span><span class="php-code">;</span>
<span class="php-brackets">}</span>
</pre></div><p>Want to see more? <a href="#">Show how to upload an image, resize it and make a thumbnail</a></p></div>
<div style="display: none;" id="image_example">
<p>This example shows how to upload an image, resize it, and make a thumbnail.</p>
<div class="code php"><pre><span class="php-comment">//</span><span class="php-comment"> Create an fUpload object to handle the file upload</span>
<span class="php-var">$uploader</span><span class="php-code"> = </span><span class="php-reserved">new</span> <span class="php-identifier">fUpload</span><span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-code">;</span>
 
<span class="php-comment">//</span><span class="php-comment"> Require the user upload an image (with MIME type checking server-side)</span>
<span class="php-var">$uploader</span><span class="php-code">-&gt;</span><span class="php-identifier">setMIMETypes</span><span class="php-brackets">(</span>
    <span class="php-reserved">array</span><span class="php-brackets">(</span><span class="php-quotes">'</span><span class="php-string">image/jpeg</span><span class="php-quotes">'</span><span class="php-code">, </span><span class="php-quotes">'</span><span class="php-string">image/gif</span><span class="php-quotes">'</span><span class="php-code">, </span><span class="php-quotes">'</span><span class="php-string">image/png</span><span class="php-quotes">'</span><span class="php-brackets">)</span><span class="php-code">,</span>
    <span class="php-quotes">'</span><span class="php-string">Please upload a .jpg, .png, or .gif image</span><span class="php-quotes">'</span>
<span class="php-brackets">)</span><span class="php-code">;</span>
 
<span class="php-comment">//</span><span class="php-comment"> Move the image and then resize to fit a 500x300 canvas</span>
<span class="php-var">$image</span><span class="php-code"> = </span><span class="php-var">$uploader</span><span class="php-code">-&gt;</span><span class="php-identifier">move</span><span class="php-brackets">(</span><span class="php-quotes">'</span><span class="php-string">/path/to/images</span><span class="php-quotes">'</span><span class="php-code">, </span><span class="php-quotes">'</span><span class="php-string">image</span><span class="php-quotes">'</span><span class="php-brackets">)</span>
<span class="php-code">                  -&gt;</span><span class="php-identifier">resize</span><span class="php-brackets">(</span><span class="php-number">500</span><span class="php-code">, </span><span class="php-number">300</span><span class="php-brackets">)</span>
<span class="php-code">                  -&gt;</span><span class="php-identifier">saveChanges</span><span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-code">;</span>
 
<span class="php-comment">//</span><span class="php-comment"> Create a 32x32 thumbnail of the image</span>
<span class="php-var">$thumb</span><span class="php-code"> = </span><span class="php-var">$image</span><span class="php-code">-&gt;</span><span class="php-identifier">duplicate</span><span class="php-brackets">(</span><span class="php-quotes">'</span><span class="php-string">/path/to/thumbs</span><span class="php-quotes">'</span><span class="php-brackets">)</span>
<span class="php-code">               -&gt;</span><span class="php-identifier">cropToRatio</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-code">,</span><span class="php-number">1</span><span class="php-brackets">)</span>
<span class="php-code">               -&gt;</span><span class="php-identifier">resize</span><span class="php-brackets">(</span><span class="php-number">32</span><span class="php-code">,</span><span class="php-number">32</span><span class="php-brackets">)</span>
<span class="php-code">               -&gt;</span><span class="php-identifier">saveChanges</span><span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-code">;</span>
</pre></div><p>Looking for the original? <a href="#">Switch back to find all users and printing their names</a></p></div>
<div class="flourish_info">
<h2 id="CuriousAboutFeatures">Curious About Features?<a title="Link to this section" class="anchor" href="http://flourishlib.com/#CuriousAboutFeatures"> ¶</a></h2>
<h3 id="Documentation">Documentation<a title="Link to this section" class="anchor" href="http://flourishlib.com/#Documentation"> ¶</a></h3>
<ul><li>It includes <a href="http://flourishlib.com/docs">extensive documentation</a> covering all code, plus the API and other general PHP topics
</li><li>It includes <a class="wiki" href="http://flourishlib.com/docs/Security">features and guidance to make sites more secure</a>
</li></ul><h3 id="Compability">Compability<a title="Link to this section" class="anchor" href="http://flourishlib.com/#Compability"> ¶</a></h3>
<ul><li>It works with PHP 5.1+
</li><li>It loves Linux/BSD, Solaris and Windows environments
</li><li>It uses <a class="wiki" href="http://flourishlib.com/docs/UTF-8">UTF-8</a> everywhere and provides <a class="wiki" href="http://flourishlib.com/docs/fUTF8">UTF-8 functions</a> even without the <a class="ext-link" href="http://php.net/mbstring"><span class="icon">mbstring</span></a> extension
</li><li>It provides <a class="wiki" href="http://flourishlib.com/docs/fNumber">precise number support</a> even without the <a class="ext-link" href="http://php.net/bc"><span class="icon">bcmath</span></a> extension
</li><li>It can <a class="wiki" href="http://flourishlib.com/docs/fImage">manipulate images</a> and automatically detects if GD or ImageMagick is installed
</li><li>It backports some PHP 5.2+ functionality to PHP 5.1 such as <a class="wiki" href="http://flourishlib.com/docs/fCookie">Httponly cookies</a> and <a class="wiki" href="http://flourishlib.com/docs/fJSON">JSON</a>
</li><li>No shell access is required, simply <a class="wiki" href="http://flourishlib.com/docs/GettingStarted">drop the classes in and go</a>
</li></ul><h3 id="DatabaseORM">Database/ORM<a title="Link to this section" class="anchor" href="http://flourishlib.com/#DatabaseORM"> ¶</a></h3>
<ul><li>It supports <a class="wiki" href="http://flourishlib.com/docs/fDatabase">MySQL, PostgreSQL, SQLite, Oracle, IBM DB2 and Microsoft SQL Server</a>
</li><li>It includes support for <a class="wiki" href="http://flourishlib.com/docs/FlourishSql">one dialect of SQL</a> across all database types
</li><li>It supports almost <a class="api" href="http://flourishlib.com/api/fDatabase" title="fDatabase">all extensions for the supported databases</a>
</li><li>It includes powerful, but intuitive <a class="wiki" href="http://flourishlib.com/docs/ObjectRelationalMapping">object-relational mapping</a> features
<ul><li>Full support and auto-exploration of <a class="wiki" href="http://flourishlib.com/docs/fActiveRecord#RelatedRecordsOperations">foreign key relationships</a>
</li><li>Simple, shorthand notation for <a class="wiki" href="http://flourishlib.com/docs/fRecordSet">querying sets of records</a>
</li><li><a class="wiki" href="http://flourishlib.com/docs/fActiveRecord#CreatingandLoadingRecords">Multi-column primary key support</a>
</li><li><a class="wiki" href="http://flourishlib.com/docs/fORM#ExtendingtheORM">A simple plugin system</a> using hooks and callbacks
</li></ul></li></ul><h3 id="AndMore">And More…<a title="Link to this section" class="anchor" href="http://flourishlib.com/#AndMore"> ¶</a></h3>
<ul><li>It includes <a class="wiki" href="http://flourishlib.com/docs/fCore">error/exception handling and debugging features</a> that make bug fixing much simpler 
</li><li>It is <a class="wiki" href="http://flourishlib.com/docs/InternationalizationLocalization">built with internationalization and localization in mind</a>
</li><li>It is <a href="http://flourishlib.com/license">licensed under the MIT license</a>
</li></ul><p>
Check out the <a href="http://flourishlib.com/docs">documentation</a> for a list of all of the Flourish classes.
</p>
</div>

	</div>
   </div>
   
  
  
  <script type="text/javascript">
   addHeadingLinks(document.getElementById("searchable"), "Link to this section");
  </script>
 
 
</div>

<script type="text/javascript">searchHighlight()</script>
<div id="altlinks"><h3>Download in other formats:</h3><ul><li class="first last"><a href="http://flourishlib.com/docs/Welcome">Plain Text</a></li></ul></div>
	<div style="clear: both;"></div>
</div>



<div id="footer">
	<div id="footer_nav">
		<ul><li class="first"><a href="http://flourishlib.com/login">Login</a></li><li class="last"><a href="http://flourishlib.com/register">Register</a></li></ul>
	</div>
	<div class="copyright">
		© 2009 Will Bond
		<a class="license" href="http://flourishlib.com/license">License</a>
		<a class="donate" href="http://flourishlib.com/docs/Support">Support</a>
	</div>
	  
	  
	  
		
	  
	<div class="clear"></div>
</div>



<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="/img/ga.js" type="text/javascript"></script>
<script type="text/javascript">
	var pageTracker = _gat._getTracker("UA-688035-5");
	pageTracker._initData();
	pageTracker._trackPageview();
</script>
<script src="/img/67539.js" type="text/javascript"></script>
<noscript><p><img alt="Clicky" width="1" height="1" src="http://static.getclicky.com/67539-db9.gif" /></p></noscript>



</body></html>